﻿<phone:PhoneApplicationPage x:Class="USElections.Vote.Pages.VotePage"
                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
                            xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
                            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                            xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
                            xmlns:nlcontrols="clr-namespace:NorthernLights.Controls;assembly=NorthernLights.Controls"
                            xmlns:conv="clr-namespace:USElections.Converters;assembly=USElections.Converters"
                            FontFamily="{StaticResource PhoneFontFamilyNormal}"
                            FontSize="{StaticResource PhoneFontSizeNormal}"
                            Foreground="{StaticResource PhoneForegroundBrush}"
                            SupportedOrientations="Portrait"
                            Orientation="Portrait"
                            mc:Ignorable="d"
                            d:DesignHeight="696"
                            d:DesignWidth="480"
                            shell:SystemTray.IsVisible="True"
                            shell:SystemTray.Opacity="0"
                            Style="{StaticResource TransitionPageStyle}">
    <phone:PhoneApplicationPage.Resources>
        <conv:PartyToColorConverter x:Key="ptc" />
        <conv:SwitchBooleanConverter x:Key="switch" />
    </phone:PhoneApplicationPage.Resources>

    <shell:SystemTray.ProgressIndicator>
        <shell:ProgressIndicator IsIndeterminate="True"
                                 IsVisible="False"
                                 Text="Sending vote..." />
    </shell:SystemTray.ProgressIndicator>

    <Grid x:Name="LayoutRoot">
        <Grid.Background>
            <ImageBrush ImageSource="/USElections.Vote;component/Images/background2.jpg"
                        Opacity="0.25"
                        AlignmentY="Top"
                        Stretch="None" />
        </Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <StackPanel x:Name="TitlePanel"
                    Grid.Row="0"
                    Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle"
                       Text="US ELECTIONS"
                       Style="{StaticResource PhoneTextNormalStyle}" />
            <TextBlock x:Name="PageTitle"
                       Text="vote"
                       Margin="9,-7,0,0"
                       Style="{StaticResource PhoneTextTitle1Style}" />
        </StackPanel>

        <Grid x:Name="ContentPanel"
              Grid.Row="1"
              Margin="12,0,12,0">
            <StackPanel>

                <toolkit:ListPicker x:Name="candidatesListPicker"
                                    Header="Your favourite candidate"
                                    FullModeHeader="CANDIDATE"
                                    CacheMode="BitmapCache">
                    <toolkit:ListPicker.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <Rectangle Fill="{Binding Party, Converter={StaticResource ptc}}"
                                           Width="24"
                                           Height="24" />
                                <TextBlock Text="{Binding FullName}"
                                           Margin="12 0 0 0" />
                            </StackPanel>
                        </DataTemplate>
                    </toolkit:ListPicker.ItemTemplate>
                    <toolkit:ListPicker.FullModeItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal"
                                        Margin="0 21 0 20">
                                <Rectangle Fill="{Binding Party, Converter={StaticResource ptc}}"
                                           Width="43"
                                           Height="43" />
                                <TextBlock Text="{Binding FullName}"
                                           Margin="16 0 0 0"
                                           FontSize="43"
                                           FontFamily="{StaticResource PhoneFontFamilyLight}" />
                            </StackPanel>
                        </DataTemplate>
                    </toolkit:ListPicker.FullModeItemTemplate>
                </toolkit:ListPicker>

                <toolkit:ListPicker x:Name="statesListPicker"
                                    Header="State in which you are registered to vote"
                                    FullModeHeader="STATE"
                                    CacheMode="BitmapCache"
                                    IsEnabled="{Binding ElementName=USCheckBox, Path=IsChecked, Converter={StaticResource switch}}">
                    <toolkit:ListPicker.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Value}"
                                           Margin="12 0 0 0" />
                            </StackPanel>
                        </DataTemplate>
                    </toolkit:ListPicker.ItemTemplate>
                    <toolkit:ListPicker.FullModeItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal"
                                        Margin="0 21 0 20">
                                <TextBlock Text="{Binding Value}"
                                           Margin="16 0 0 0"
                                           FontSize="43"
                                           FontFamily="{StaticResource PhoneFontFamilyLight}" />
                            </StackPanel>
                        </DataTemplate>
                    </toolkit:ListPicker.FullModeItemTemplate>
                </toolkit:ListPicker>

                <CheckBox x:Name="USCheckBox"
                          Content="Not a US citizen" />

                <TextBlock TextWrapping="Wrap"
                           Style="{StaticResource PhoneTextSubtleStyle}">
                    Note that you can change your vote as often as you want, but your vote will only be counted once.
                </TextBlock>
            </StackPanel>
        </Grid>

        <nlcontrols:Notification x:Name="notification" />
    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True"
                              IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Icons/appbar.check.png"
                                            Text="vote"
                                            Click="ApplicationBarIconButtonClick" />
            <shell:ApplicationBarIconButton IconUri="/Icons/appbar.share.rest.png"
                                            Text="share"
                                            IsEnabled="False"
                                            Click="ApplicationBarIconButtonClick" />
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
</phone:PhoneApplicationPage>
